<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>管理中心</title>
<%@ include file="/common/include.jsp"%>
<link href="/summer/template/admin/css/input.css" rel="stylesheet"
	type="text/css" />
<link href="/summer/template/admin/css/input.css" rel="stylesheet" type="text/css" />
<meta name="Author" content="SHOP++ Team" />
<meta name="Copyright" content="SUMMER" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<script type="text/javascript">

function tab(a)
{
if(a=="2")
{
	
	$('#table2').show();
	$('#table1').hide();
}
else
{
	$('#table1').show();
	$('#table2').hide();
}

}

function showTips( tips, height, time ){ 
	var windowWidth = document.documentElement.clientWidth; 
	var tipsDiv = '<div class="tipsClass">' + tips + '</div>'; 

	$( 'body' ).append( tipsDiv ); 
	$( 'div.tipsClass' ).css({ 
	'top' : height + 'px', 
	'left' : ( windowWidth / 2 ) - ( tips.length * 13 / 2 ) + 'px', 
	'position' : 'absolute', 
	'padding' : '3px 5px', 
	'background': '#8FBC8F', 
	'font-size' : 12 + 'px', 
	'margin' : '0 auto', 
	'text-align': 'center', 
	'width' : 'auto', 
	'color' : '#fff', 
	'opacity' : '0.8' 
	}).show(); 

	setTimeout( function(){$( 'div.tipsClass' ).fadeOut();}, ( time * 1000 ) ); 
	} 



$().ready( function() {
	$upImg=$(".upImg");
	$delImg=$(".delImg");
	
	// 保存
	$upImg.click( function() {
		var url = $(this).attr("src");
		if (confirm("您确定要上传到宝贝上吗？") == true) {
			$.ajax({
				url: "goods!upImg.action?img_url="+url,
				data: {"id":'${id}'},
				dataType: "json",
				type: "post", //可以避免get方式提交乱码
				async: false,
				beforeSend: function(data) {
					//$saveButton.attr("disabled", true)
				},
				success: function(data) {
					if (data.status == "success") {
						showTips( data.message, 100, 3 );
					}
					$.message(data.status, data.message);
				}
			});
		}
	});


	// 保存
	$delImg.click( function() {
		
		var img_id = $(this).attr("id");
			$.ajax({
				url: "goods!delImg.action?img_id="+img_id+"&id=${id}",
				data: {"num_iid":'${goods.num_iid}'},
				dataType: "json",
				type: "post", //可以避免get方式提交乱码
				async: false,
				beforeSend: function(data) {
					//$saveButton.attr("disabled", true)
				},
				success: function(data) {
					if (data.status == "success") {
						showTips( "删除成功", 100, 3 );
					}
					$.message(data.status, data.message);
				}
			});
	});


	

});

</script>
</head>


<body class="input" onload="tab('1')">
	<div class="body">
				<div class="inputBar">
			<h1><span class="icon">&nbsp;</span>
			<s:if test="id==null">添加产品 </s:if><s:else>编辑产品</s:else>
			</h1>
		</div>
		<form id="inputForm" class="validate" action="<s:if test="id==null">goods!save.action</s:if><s:else>goods!update.action</s:else>" method="post">
			<input type="hidden" name="redirectionUrl" value="goods!list.action?pager.pageNumber=${pager.pageNumber}&pager.property=name&pager.keyword=<s:property value="@java.net.URLEncoder@encode(pager.keyword,'utf-8')"/>" />
			<input type="hidden" name="goods.id" value="${id}" />
			<input type="hidden" name="goods.createDate" value="${goods.createDate}" />
			<s:iterator value="pager.searchMap" var="searchMap">
  					<input type="hidden" name="pager.searchMap['${searchMap.key}']" value="${searchMap.value}">
			</s:iterator>
			<div class="blank"></div>
			<ul class="tab">
				<li>
					<input type="button" value="基本信息" hidefocus="true" onclick="tab(1)" />
				</li>
				<li>
					<input type="button" value="详细资料" hidefocus="true"  onclick="tab(2)"/>
				</li>
			</ul>
			<table id="table1"  class="inputTable tabContent">
				<tr>
					<th>
						参考属性:
					</th>
					<td>
						<b>${goods.propsName}</b>
					</td>
				</tr>
				<tr>
					<th>
						商品名称:
					</th>
					<td>
					<s:if test="id==null">
							<input type="text" name="goods.name" class="formText {required: true, username: true, remote: 'goods!checkUsername.action', minlength: 2, maxlength: 20, messages: {remote: '用户名已存在,请重新输入!'}}" title="用户名只允许包含中文、英文、数字和下划线" />
							<label class="requireField">*</label>
						</s:if><s:else>
							<input type="text"  style="width: 600" class="formText"name="goods.name" value="${goods.name}" />
						</s:else>
					</td>
				</tr>
				<tr>
					<th>
						品牌:
					</th>
					<td>
						<input type="text" name="goods.pinpai" class="formText" value="${goods.pinpai}" />
					</td>
				</tr>
				<tr>
					<th>
						型号:
					</th>
					<td>
						<input type="text" name="goods.xinghao" class="formText" value="${goods.xinghao}" />
					</td>
				</tr>
				<tr>
					<th>
						销售价格:
					</th>
					<td>
						<input type="text" name="goods.price" class="formText" value="${goods.price}" />
					</td>
				</tr>
				<tr>
					<th>
						淘宝地址:
					</th>
					<td>
						<input type="text" name="goods.tb_url" class="formText" value="${goods.tb_url}" />
					</td>
				</tr>
				<tr>
				<th>图片情况(单击删除)</th><td>
						<s:iterator value="goods.imgsSet">
						<a href="${goods.tb_url}" target="_blank"><img  style="width: 100px;height:85px" src="<s:property value='img_url' />"  /> </a>
						<a class="delImg" id="<s:property value='img_id' />" href="#" >[删除]</a>
						</s:iterator>
				</td>
				</tr>
				
				<tr>
				<th>其他商城图片(单击上传)</th><td>
						<s:iterator value="goods.good" > 
						<s:iterator value="%{pic_url.split(';')}" var="t">
						<img class="upImg"  style="width: 100px;height:85px" src="<s:property value='t' />"  /> 
						</s:iterator>
						</s:iterator>
				</td>
				</tr>
				
				
				
				<tr>
				<th>手工搜索</th>
				<td>
					<s:iterator value="shopList" var="tt">
						<a href='<s:property value="searchKey" /><s:property value="@java.net.URLEncoder@encode(goods.pinpai+' '+goods.xinghao,'gb2312')"/>' title="<s:property value='name'/>" target="_blank">[<s:property value="cnName"/>]</a>
					</s:iterator>
				</td>
				</tr>
					
			</table>
			<table id="table2"  class="inputTable tabContent">
				<tr>
					<td colspan="2">
					<FCK:editor instanceName="goods.description" value="${goods.description}" width="100%" height="1000"> </FCK:editor> 
					</td>
				</tr>
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton"  value="确  定" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
			</div>
		</form>
	</div>
	
	<div>
	<iframe src="good!list.action?goods_id=${goods.id}" width="100%"  frameborder=0  height="100%" marginheight=0 marginwidth=0 scrolling=no  ></iframe>
	</div>

</body>
</html>